package leetcode_top;


public class Ex387 {
    class Solution {
        public int firstUniqChar(String s) {
            int[] nums = new int[26];
            for (char c: s.toCharArray()) {
                nums[c - 'a']++;
            }
            for (int i = 0; i < s.length(); i++) {
                if (nums[s.charAt(i) - 'a'] == 1) {
                    return i;
                }
            }
            return -1;
        }
    }
}
